package com.acwing.partition46;

import java.io.*;

/**
 * @author rkc
 * @date 2022/7/22 9:19
 */
public class AC4518最低票价 {

    private static final int N = 370;
    private static int[] days = new int[N], f = new int[N];
    private static int n, c1, c7, c30;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt();
        for (int i = 1; i <= n; i++) days[i] = nextInt();
        c1 = nextInt(); c7 = nextInt(); c30 = nextInt();
        writer.println(dp());
        writer.flush();
    }

    private static int dp() {
        for (int i = 1, j7 = 0, j30 = 0; i <= n; i++) {
            //找出小于等于7天的最大天数之前的花费上，再买一张7天的票
            while (days[i] - days[j7 + 1] >= 7) j7++;
            while (days[i] - days[j30 + 1] >= 30) j30++;
            f[i] = min(f[i - 1] + c1, f[j7] + c7, f[j30] + c30);
        }
        return f[n];
    }

    private static int min(int... args) {
        int res = args[0];
        for (int i = 1; i < args.length; i++) res = Math.min(res, args[i]);
        return res;
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
